package com.example.night.controller;

import com.example.night.data.Influencer.Influencer;
import com.example.night.data.Influencer.InfluencerPackage;
import com.example.night.service.ApiService.InfluencerSummaryService;
import com.example.night.service.TimeService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/influencers")
public class InfluencerController {

    private final InfluencerSummaryService influencerSummaryService;
    private final TimeService timeService;

    public InfluencerController(InfluencerSummaryService influencerSummaryService, TimeService timeService) {
        this.influencerSummaryService = influencerSummaryService;
        this.timeService = timeService;
    }


    @GetMapping("/get_influencers_Ranking")
    public Map<String, Object> getInfluencersRanking(
            @RequestParam String start_time,
            @RequestParam String end_time,
            @RequestParam int type,
            @RequestParam String promoterId,
            @RequestParam int page
    ) {
        List<InfluencerPackage> influencersRanking;
        influencersRanking = influencerSummaryService.fetchInfluencers(start_time, end_time, page, type, promoterId);
        return Map.of(
                "total_ranking", influencersRanking.size(),
                "ranking", influencersRanking,
                "success", true
        );
    }
}
